# 循环

# while循环数字炸弹
import random
num1,num2 = int(input("请输入最小范围：")),int(input("请输入最大范围："))
if num1 > num2: num1,num2 = num2,num1
rd = random.randint(num1,num2)
print(rd)
num = int(input("游戏开始，请输入一个{0}-{1}的数字：".format(num1,num2)))
while num != rd :
    if num > rd & num < num2:
        num2 = num
        num = int(input("{0}--{1}请输入一个数字：".format(num1,num2)))
    elif num < rd & num > num1:
        num1 = num
        num = int(input("{0}--{1}请输入一个数字：".format(num1,num2)))
    else:
        print("你输入的数字有误，请重新输入！")
        continue
    if num == rd:
        print("数字是{0}你出局了！".format(num))
        break
else:print("数字是{0}你出局了！".format(num))


# for循环计算累加和
# sum = 0
# sum1 = 0
# sum2 = 0
# num = int(input("请输入数字："))
# for item in range(num+1):
#     sum += item
#     if item % 2 == 0:
#         sum1 += item
#     else:
#         sum2 += item
# print("{0}以内整数累加和：{1}".format(num,sum))
# print("{0}以内偶数累加和：{1}".format(num,sum1))
# print("{0}以内奇数累加和：{1}".format(num,sum2))

# 嵌套循环打印乘法表
# i = 1
# while i < 10:
#     j = 1
#     while j <= i:
#         print("{0}*{1}={2}".format(i,j,i * j),end="\t")
#         j += 1
#     i += 1
#     print()
#
# for i in range(1,10):
#     for j in range(1,i+1):
#         print("{0}*{1}={2}".format(i, j, i * j), end="\t")
#     print()